﻿from System import Single
from System import Math
from System.Drawing import Color
from System.Windows.Forms import Keys
from SlimDX import *
from starpillage import *

yPos = 30

def initCam():
	cam = game.Camera
	cam.FieldOfView = Single(Math.PI / 3)
	cam.NearPlane = Single(1.0)
	cam.FarPlane = Single(1000.0)
	cam.Location = Vector3(-30.0, yPos, -30.0)
	cam.Target = Vector3(128.0, yPos, 128.0)
initCam()

def move(speed):
	cam = game.Camera
	d = (cam.Target - cam.Location)
	cam.Location = cam.Location + d * speed
	cam.Target = cam.Location + d

def turn(speed):
	cam = game.Camera
	d = (cam.Target - cam.Location)
	m = Matrix.RotationY(speed)
	cam.Target = cam.Location + Vector3.TransformNormal(d, m)

moveSpeed = Single(0.01)
turnSpeed = Single(0.1)

def moveForward(t):
	move(moveSpeed)

def moveBack(t):
	move(-moveSpeed)
	
def turnLeft(t):
	turn(-turnSpeed)
	
def turnRight(t):
	turn(turnSpeed)

game.Keyboard.RegisterKeyAction(Keys.Up, moveForward);
game.Keyboard.RegisterKeyAction(Keys.Down, moveBack);
game.Keyboard.RegisterKeyAction(Keys.Left, turnLeft);
game.Keyboard.RegisterKeyAction(Keys.Right, turnRight);

game.Console.WriteLine("Starpillage")